/*
 * $RCSfile: Table.java,v $
 * $Revision: 1.3 $
 *
 * Comments:
 *
 * (C) Copyright Biuro-Technika 2007.  All rights reserved.
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Biuro-Technika
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 *
 * $Author: michal $          $Locker:  $
 * $Date: 2010/05/24 10:44:25 $
 * $Log: Table.java,v $
 * Revision 1.3  2010/05/24 10:44:25  michal
 * parametryzacja kodu
 *
 * Revision 1.2  2007/08/24 09:13:13  dominik
 * Dodanie nowego konstruktora
 *
 * Revision 1.1  2007/08/21 09:21:25  dominik
 * Reprezentacja Tablicy
 *
 */

package parasoft.centrap.migration;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

public class Table {

	private long oid;
	private String tableName;
	private Vector<Column> columns;
	private String owner;
	
	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public Table(long _oid, String name, String _owner) {
		this.oid = _oid;
		this.tableName = name;
		this.owner = _owner;
		this.columns = new Vector<Column>();
	}
	
	public Table(String name) {
		this.tableName = name;
		this.columns = new Vector<Column>();
	}

	public Vector<Column> getColumns() {
		return columns;
	}

	public long getOid() {
		return oid;
	}

	public String getTableName() {
		return tableName;
	}
	
	public void addColumn(Column column){
		columns.add(column);
	}
	
	public Column getColumn(String columnName){
		for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) {
			Column column = iter.next();
			if (column.getColumnName().equals(columnName)){
				return column;
			}
		}
		return null;
	}
	
	
	public void wypisz(){
		for(Enumeration<Column> e = columns.elements(); e.hasMoreElements();){
			Column c = e.nextElement();
			System.out.print(tableName+"  "+c.getColumnName()+"  "+c.getType());
			if (c.isPrimaryKey()){
				System.out.println("  "+c.isPrimaryKey());
			} else {
				System.out.println();
			}
		}
		
	}
	
	
}
